package ascript.utilities
{
	//#########################
	// Header Includes
	//#########################
	import starling.textures.Texture;
	import starling.display.Image;
	import starling.display.Sprite;
	import starling.display.MovieClip;
	import starling.animation.Juggler;
	import starling.core.Starling;
	import starling.textures.TextureAtlas;

	//#########################
	// GraphicsAnimated Class
	//#########################
	public class GraphicsFlipbook extends Sprite
	{
		//=========================
		// Variables
		//=========================
		private var graphicImage:Image;
		private var graphicTextures:Vector.<Texture>;
		private var graphicTexturesIndex:uint;
		
		//=========================
		// Constructors
		//=========================	
		public function GraphicsFlipbook( tTextures:Vector.<Texture>, tIsVisible:Boolean, tLocation:PointSimple, tPivot:PointSimple, tIndex:uint ):void
		{
			graphicTextures = tTextures;
			graphicImage = new Image( graphicTextures[ tIndex ] );
			
			x = tLocation.x;
			y = tLocation.y;
			pivotX = tPivot.x;
			pivotY = tPivot.y;
			visible = tIsVisible;
			
			setIndexGraphic( tIndex );
			addChild( graphicImage );
		}
		
		//=========================
		// Members
		//=========================
		public function setIndexGraphic( tIndex:uint ):void
		{
			if ( tIndex > 0 && tIndex < graphicTextures.length && tIndex != graphicTexturesIndex )
			{
				graphicTexturesIndex = tIndex;
				graphicImage = new Image( graphicTextures[ graphicTexturesIndex ] );
			}
		}
		
		public function getIndexGraphic():int
		{
			return graphicTexturesIndex;
		}
	}
}